Demo of data visualization dashboard

Sean Chang, July 2016
In [101]:
# this is a data viz dashboard based on ipython notebook
# ipynb can be executed and save to html from command line
# usage: run daily to generate performance reports
# input: csv data
# output: html report w interactive plots + without any additional library 
In [ ]:
# to execute from shell, run python script like the following:

def build_arg_parser():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        '--currency', help="get currency",
        type=str, required=True)
    return parser

if __name__ == '__main__':
    NS = build_arg_parser().parse_args()

    os.environ['date'] = str(NS.date)

    report_path = 'data_visualization_dashboard'

    if call(["ipython", "nbconvert", "--to=html",
             "--execute", report_path, '.ipynb',
             "--ExecutePreprocessor.timeout=270"]):
        raise Exception('failed to run ipython notebook')
In [102]:
import numpy as np
import pandas as pd

from datetime import datetime
from bokeh.io import output_notebook
from bokeh.plotting import figure, show
from bokeh.charts import TimeSeries
from IPython.display import display
from subprocess import call
TOOLS = "pan, box_zoom, reset, save, box_select"
output_notebook()
Loading BokehJS ...
In [105]:
def plotter(currency):
    dat = pd.read_csv('data/{currency}USD.csv'.format(currency = currency))
    dat['time'] = pd.to_datetime(dat.time).apply(lambda x: x.date()).apply(pd.to_datetime)
    p = TimeSeries(dat2, x = 'time', y = 'rate', title = currency, 
                   ylabel='exchange rate', xlabel='date')
    show(p)
In [107]:
currencies = ['JPY', 'AUD', 'EUR', 'GBP', 'NZD']
for currency in currencies: 
    plotter(currency)